import java.time.LocalTime;

public class B1 {
    private int temperature = 20;
    private int waterLevel = 0;
    private String state = "Idle";
    private boolean isRepairMode = false;

    public int getTemperature() {
        return temperature;
    }

    public boolean hasWater() {
        return waterLevel > 0;
    }

    public LocalTime getCurrentTime() {
        return LocalTime.now();
    }

    public void heaterOn() {
        System.out.println("Heater is on");
    }

    public void heaterOff() {
        System.out.println("Heater is off");
    }

    public void enterRepairMode() {
        isRepairMode = true;
        System.out.println("Water tank needs repair!");
    }

    public void exitRepairMode() {
        isRepairMode = false;
        System.out.println("Water tank repair completed!");
    }

    public void sleepMode() {
        System.out.println("System is in sleep mode, power is off.");
    }

    public void wakeUp() {
        System.out.println("System is awake, entering heating mode.");
    }

    public void transition() {
        LocalTime currentTime = getCurrentTime();
        int hour = currentTime.getHour();
        int minute = currentTime.getMinute();

        if (hour == 23 && minute == 0) {
            state = "Idle";
            sleepMode();
            return;
        }

        if (hour == 7 && minute == 0) {
            state = "Heating";
            wakeUp();
            return;
        }

        if (state.equals("Idle")) {
            if (getTemperature() < 20 && hasWater()) {
                state = "Heating";
                heaterOn();
            }
        } else if (state.equals("Heating")) {
            if (getTemperature() >= 100) {
                state = "PowerOff";
                heaterOff();
            } else if (isRepairMode) {
                state = "Repair";
                heaterOff();
            }
        } else if (state.equals("PowerOff")) {
            if (getTemperature() < 20 && hasWater()) {
                state = "Heating";
                heaterOn();
            }
        } else if (state.equals("Repair")) {
            // Waiting for repair to be completed
        }
    }

    public static void main(String[] args) {
        B1 tank = new B1();

        while (true) {
            tank.transition();
            try {
                Thread.sleep(1000); // Sleep for 1 second before the next transition
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
